<template>


  <el-dialog
      v-model="dialogVisible.img "
      :title="dialogVisible.tetle"
      width="30%"
      :before-close="handleClose"
      fullscreen = "true"
  >
    <el-image :src="dialogVisible.imageFlow" class="imgFlow" v-if="dialogVisible.ifelse===1"></el-image>
    <span v-if="dialogVisible.ifelse===2">
      {{dialogVisible.imageFlow}}

    </span>

    <template #footer>
      <span class="dialog-footer">
<!--        <el-button @click="dialogVisible.img  = false">Cancel</el-button>-->
        <el-button type="primary" @click="dialogVisible.img  = false">
          确定
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import {ref, toRefs, watch} from 'vue'
import { ElMessageBox } from 'element-plus'

const props =defineProps({
  dialogVisibleIMG: {
    type: Object,
    default: "",
  },
});
const propsData = toRefs(props)
console.log(propsData.dialogVisibleIMG.value.imageFlow,"fgg")

const emits = defineEmits(['update:dialogVisibleIMG']) // 此处需写'update'
// 流程xml /图片 的对象
let dialogVisible = ref({
  img:false,
  imageFlow:"",
  ifelse :0
  ,tetle:""
})
//把监听父组件的值赋值给子组件的新值
watch(propsData.dialogVisibleIMG, (val, old) => {
  dialogVisible.value = val
})
console.log(dialogVisible,"val")

//然后在监听子组件的新值
watch(dialogVisible, (val, old) => {
  emits('update:dialogVisibleIMG', val) // 此处的update亦要写
})
const handleClose = (done: () => void) => {
  ElMessageBox.confirm('Are you sure to close this dialog?')
      .then(() => {
        done()
      })
      .catch(() => {
        // catch error
      })
}
</script >
<style scoped>
.dialog-footer button:first-child {
  margin-right: 10px;
}

.imgFlow{
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

</style>
